package com.um.springboot.starter.exception;

import cn.dev33.satoken.exception.NotPermissionException;
import com.um.springboot.starter.code.CommonCode;
import com.um.springboot.starter.orm.entity.Response;
import org.springframework.core.annotation.Order;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * @author 甘天伟
 * @date 2025/3/7
 * 版权所有 广州优匠科技有限公司
 */
@Order(11)
@ControllerAdvice
public class NotPermissionExceptionHandler {

    @ExceptionHandler(NotPermissionException.class)
    @ResponseBody
    public Response handleException(NotPermissionException e) {
        return Response.failed(CommonCode.NoApiPermission);
    }

}
